package com.requiem.hist_group_manage_springboot.exception;

import com.requiem.hist_group_manage_springboot.constants.SystemConstants;
import lombok.Data;

@Data
public class R {
    private int code;
    private String msg;
    private Object data;

    public static R error(int code, String msg) {
        R r = new R();
        r.code = code;
        r.msg = msg;
        r.data = null;
        return r;
    }

    public static R success() {
        R r = new R();
        r.code = SystemConstants.SUCCESS_CODE;
        r.msg = SystemConstants.SUCCESS_MSG;
        r.data = null;
        return r;
    }

    public static R success(String msg) {
        R r = new R();
        r.code = SystemConstants.SUCCESS_CODE;
        r.msg = msg;
        r.data = null;
        return r;
    }

    public static R success(Object data) {
        R r = new R();
        r.code = SystemConstants.SUCCESS_CODE;
        r.msg = SystemConstants.SUCCESS_MSG;
        r.data = data;
        return r;
    }
}
